package com.vodone.v1pin.userInfo.delegate
{
	import com.vodone.v1pin.userInfo.vo.AddressVO;
	
	import mx.collections.ArrayCollection;

	public class AddressUtil
	{
		public static function getAddressListFromObj(obj:Object):ArrayCollection
		{
			var list:ArrayCollection = new ArrayCollection();
			if(obj && obj is Array)
			{
				var arr:Array = obj as Array;
				if(arr && arr.length > 0)
				{
					for(var i:int = 0; i< arr.length ; i++)
					{
						list.addItem(getAddressItem(arr[i]));
					}
				}
			}
			return list;
		}
		public static function getAddressItem(obj:Object):AddressVO
		{
			var item:AddressVO = new AddressVO();
			if(obj)
			{
				if(obj.hasOwnProperty("id"))
				{
					item.id = obj["id"];
				}
				if(obj.hasOwnProperty("name"))
				{
					item.name = obj["name"];
				}
				if(obj.hasOwnProperty("provinceCode"))
				{
					item.provinceCode = obj["provinceCode"];
				}
				if(obj.hasOwnProperty("provinceName"))
				{
					item.provinceName = obj["provinceName"];
				}
				if(obj.hasOwnProperty("cityCode"))
				{
					item.cityCode = obj["cityCode"];
				}
				if(obj.hasOwnProperty("cityName"))
				{
					item.cityName = obj["cityName"];
				}
				if(obj.hasOwnProperty("areaCode"))
				{
					item.areaCode = obj["areaCode"];
				}
				if(obj.hasOwnProperty("areaName"))
				{
					item.areaName = obj["areaName"];
				}
				if(obj.hasOwnProperty("address"))
				{
					item.address = obj["address"];
				}
				if(obj.hasOwnProperty("postCode"))
				{
					item.postCode = obj["postCode"];
				}
				if(obj.hasOwnProperty("mobile"))
				{
					item.mobile = obj["mobile"];
				}
				if(obj.hasOwnProperty("phone"))
				{
					item.phone = obj["phone"];
				}
				if(obj.hasOwnProperty("isDefault"))
				{
					item.isDefault = obj["isDefault"];
				}
			}
			return item;
		}
	}
}